package com.huike.web.controller.business;

import com.huike.business.domain.TbBusiness;
import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.domain.vo.BusinessTrackVo;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.clues.domain.TbClue;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.utils.SecurityUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.controller.BaseController;

/**
 * 商机跟进记录Controller
 *
 * @date 2021-04-28
 */
@RestController
@RequestMapping("/business/record")
public class TbBusinessTrackRecordController extends BaseController {
    @Autowired
    ITbBusinessTrackRecordService iTbBusinessTrackRecordService;
    @PostMapping
    public AjaxResult addBusinessTrackRecord(@RequestBody BusinessTrackVo businessTrackVo) {
        TbBusinessTrackRecord tbBusinessTrackRecord = new TbBusinessTrackRecord();
        BeanUtils.copyProperties(businessTrackVo, tbBusinessTrackRecord);
        tbBusinessTrackRecord.setCreateBy(SecurityUtils.getUsername());
        TbBusiness tbBusiness = new TbBusiness();
        BeanUtils.copyProperties(tbBusinessTrackRecord,tbBusiness);
        tbBusiness.setStatus(TbBusiness.StatusType.FOLLOWING.getValue()); //进行中
        tbBusiness.setId(tbBusinessTrackRecord.getBusinessId());
        return toAjax(iTbBusinessTrackRecordService.insertTbBusinessTrackRecord(tbBusinessTrackRecord));
    }
}
